<template>
  <div class="header">
    <div class="left">
      <div class="menu-icon">
        <el-icon size="26px" color="#fff">
          <component @click="foleHandle" :is="isFole ? 'Fold' : 'Expand'" />
        </el-icon>
      </div>
      <el-breadcrumb :separator-icon="ArrowRight">
        <el-breadcrumb-item :to="{ path: '/' }">homepage</el-breadcrumb-item>
        <el-breadcrumb-item>promotion management</el-breadcrumb-item>
        <el-breadcrumb-item>promotion list</el-breadcrumb-item>
      </el-breadcrumb>
      <div class="breadBtn">CoderKu 体验版</div>
    </div>
    <div class="right">
      <div class="text">
        <el-dropdown>
          <div>
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </div>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>Action 2</el-dropdown-item>
              <el-dropdown-item divided>项目地址</el-dropdown-item>
              <el-dropdown-item>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { LOGIN_TOKEN } from '@/global/constants';
import { useRouter } from 'vue-router';
import Storage from '@/utils/Storeage';
import { ArrowRight } from '@element-plus/icons-vue';

const emit = defineEmits(['isWidth']);

const router = useRouter();
const isFole = ref(false);

const foleHandle = () => {
  isFole.value = !isFole.value;
  emit('isWidth', isFole.value);
};

const quitFn = () => {
  Storage.remove(LOGIN_TOKEN);
  router.push('/login');
};
</script>

<style lang="less" scoped>
.header {
  display: flex;
  height: 100%;
  justify-content: space-between;
  align-items: center;

  .left {
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;

    :deep(.el-breadcrumb__inner) {
      color: #ddd;
    }
    :deep(.el-breadcrumb__inner.is-link) {
      color: #fff;
    }

    .menu-icon {
      margin: 0 15px;
    }

    .breadBtn {
      background: #84a9fe;
      font-size: 14px;
      padding: 0 10px;
      color: #fff;
      height: 30px;
      line-height: 30px;
      border-radius: 10px;
      margin-left: 15px;
    }
  }

  .flex-grow {
    flex-grow: 1;
  }
}
</style>
